package com.huawei.appgallery.forum.user.usercenter.widget;

import android.content.Context;
import android.content.res.TypedArray;
import android.util.AttributeSet;
import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup.MarginLayoutParams;
import android.widget.ImageView;
import android.widget.LinearLayout;
import android.widget.RelativeLayout;
import android.widget.RelativeLayout.LayoutParams;
import android.widget.TextView;
import com.huawei.appgallery.forum.base.card.bean.User;
import com.huawei.appgallery.forum.cards.widget.UserInfoTextView;
import com.huawei.appgallery.forum.cards.widget.UserInfoTextView.e;
import o.azb;
import o.bqx;
import o.bsx;
import o.bsy;
import o.cbb;
import o.cbb.b;
import o.cbb.d;
import o.cbb.i;
import o.dof;
import o.epv;

public class CommentReferenceUserView extends RelativeLayout implements e {
    private Context ʻ;
    private String ʼ;
    private String ʽ = "";
    private int ˊ;
    private LinearLayout ˋ;
    private TextView ˎ;
    private ImageView ˏ;
    private UserInfoTextView ॱ;
    private int ॱॱ = 0;
    private TextView ᐝ;

    public CommentReferenceUserView(Context context) {
        super(context);
        ˋ(context);
        ˏ(null);
    }

    public CommentReferenceUserView(Context context, AttributeSet attributeSet) {
        super(context, attributeSet);
        ˋ(context);
        ˏ(attributeSet);
    }

    public CommentReferenceUserView(Context context, AttributeSet attributeSet, int i) {
        super(context, attributeSet, i);
        ˋ(context);
        ˏ(attributeSet);
    }

    public void setDomainId(String str) {
        this.ʽ = str;
    }

    private void ˋ(Context context) {
        this.ʻ = context;
        View inflate = LayoutInflater.from(context).inflate(d.ˊॱ, this);
        this.ॱ = (UserInfoTextView) inflate.findViewById(b.ˋᐝ);
        this.ˏ = (ImageView) inflate.findViewById(b.ʽ);
        this.ˎ = (TextView) inflate.findViewById(b.ॱॱ);
        this.ˋ = (LinearLayout) inflate.findViewById(b.ˍ);
        this.ᐝ = (TextView) inflate.findViewById(b.ͺ);
        this.ॱ.setFakeView(this.ᐝ);
        this.ॱ.setUserFakeViewChangeListener(this);
        ˋ(this.ˏ);
        ˋ(this.ᐝ);
    }

    private void ˋ(View view) {
        if (view != null) {
            view.setOnClickListener(new 5(this));
        }
    }

    private void ˏ(AttributeSet attributeSet) {
        TypedArray obtainStyledAttributes;
        Throwable e;
        if (attributeSet != null) {
            TypedArray typedArray = null;
            try {
                obtainStyledAttributes = getContext().obtainStyledAttributes(attributeSet, i.ॱꜟ);
                try {
                    this.ˊ = obtainStyledAttributes.getInteger(i.ॱﾞ, 0);
                    LayoutParams layoutParams = (LayoutParams) this.ˏ.getLayoutParams();
                    layoutParams.width = epv.ˋ(this.ˏ.getContext(), this.ˊ);
                    layoutParams.height = epv.ˋ(this.ˏ.getContext(), this.ˊ);
                    if (this.ˊ == 32) {
                        MarginLayoutParams marginLayoutParams = (MarginLayoutParams) this.ˋ.getLayoutParams();
                        marginLayoutParams.setMarginStart(epv.ˋ(this.ˋ.getContext(), 8));
                        this.ˋ.setLayoutParams(marginLayoutParams);
                        LinearLayout.LayoutParams layoutParams2 = (LinearLayout.LayoutParams) this.ˎ.getLayoutParams();
                        layoutParams2.topMargin = 0;
                        this.ˎ.setLayoutParams(layoutParams2);
                        this.ॱ.setNickNameTextSize(getContext().getResources().getDimension(cbb.e.ʼ));
                    }
                    this.ˏ.setLayoutParams(layoutParams);
                    if (obtainStyledAttributes != null) {
                        obtainStyledAttributes.recycle();
                    }
                } catch (RuntimeException e2) {
                    e = e2;
                    typedArray = obtainStyledAttributes;
                    try {
                        bqx.ˊ("CommentReferenceUserView", "init(AttributeSet attrs) ", e);
                        if (typedArray != null) {
                            typedArray.recycle();
                        }
                    } catch (Throwable th) {
                        e = th;
                        obtainStyledAttributes = typedArray;
                        if (obtainStyledAttributes != null) {
                            obtainStyledAttributes.recycle();
                        }
                        throw e;
                    }
                } catch (Throwable th2) {
                    e = th2;
                    if (obtainStyledAttributes != null) {
                        obtainStyledAttributes.recycle();
                    }
                    throw e;
                }
            } catch (RuntimeException e3) {
                e = e3;
                bqx.ˊ("CommentReferenceUserView", "init(AttributeSet attrs) ", e);
                if (typedArray != null) {
                    typedArray.recycle();
                }
            } catch (Throwable th3) {
                e = th3;
                obtainStyledAttributes = null;
                if (obtainStyledAttributes != null) {
                    obtainStyledAttributes.recycle();
                }
                throw e;
            }
        }
    }

    public void setUser(User user) {
        this.ॱ.setVisibility(0);
        if (this.ˊ == 32) {
            this.ॱ.setContentWidth((((azb.ॱ(this.ʻ) - (this.ʻ.getResources().getDimensionPixelOffset(bsy.e.ʿ) * 3)) - this.ʻ.getResources().getDimensionPixelOffset(bsy.e.ˎˎ)) - (this.ʻ.getResources().getDimensionPixelOffset(bsy.e.ॱˎ) * 3)) - this.ʻ.getResources().getDimensionPixelOffset(bsy.e.ˉ));
        }
        if (user != null) {
            bsx.ˋ(this.ʻ, this.ˏ, user.ˎ());
            this.ॱ.setData(user);
            this.ʼ = user.ॱ();
            this.ॱॱ = user.ˊ();
            return;
        }
        bsx.ˋ(this.ʻ, this.ˏ, "");
        this.ॱ.setVisibility(4);
        this.ʼ = null;
        this.ॱॱ = 0;
    }

    public void setSectionName(String str) {
        if (dof.ʽ(str)) {
            this.ˎ.setVisibility(4);
            return;
        }
        this.ˎ.setVisibility(0);
        this.ˎ.setText(str);
    }

    public void ˊ(int i) {
        this.ᐝ.setWidth(getResources().getDimensionPixelSize(cbb.e.ॱॱ) + i);
    }
}
